package com.catmai.pssmanager.service.impl;

import java.sql.SQLException;
import java.util.List;
import java.util.Vector;

import com.catmai.pssmanager.dao.StoreHouseDao;
import com.catmai.pssmanager.dao.impl.StoreHouseDaoImpl;
import com.catmai.pssmanager.po.Storehouse;
import com.catmai.pssmanager.service.StoreHouseService;

public class StoreHouseServiceImpl implements StoreHouseService{
	
	private StoreHouseDao storeHouse = new StoreHouseDaoImpl();
	
	@Override
	public Vector<Vector> findAll() throws SQLException {
		Vector<Vector> rows = new Vector<>();
		List<Storehouse> list = storeHouse.findAll();
		if(!list.isEmpty()) {
			for (Storehouse storehouse : list) {
				Vector temp = new Vector<>();
				temp.add(storehouse.getStorehouse_Id());
				temp.add(storehouse.getStorehouse_Address());
				temp.add(storehouse.getStorehouse_Capacity());
				temp.add(storehouse.getStorehouse_Stock());
				rows.add(temp);
			}
		}
		return rows;
	}

	@Override
	public void saveObject(Storehouse storehouse) throws SQLException {
		storeHouse.saveObject(storehouse);
	}

	@Override
	public void deleteObject(Integer storehouseId) throws SQLException {
		storeHouse.deleteObject(storehouseId);
	}

	@Override
	public void updateObject(Storehouse storehouse) throws SQLException {
		storeHouse.updateObject(storehouse);
	}

	@Override
	public Storehouse getHouseById(Integer storehouseId) throws SQLException {
		return storeHouse.getStorehouseById(storehouseId);
	}

}
